package com.xuecheng.manage_cms.service.impl;

import com.xuecheng.framework.domain.cms.CmsSite;
import com.xuecheng.framework.model.response.CommonCode;
import com.xuecheng.framework.model.response.QueryResponseResult;
import com.xuecheng.framework.model.response.QueryResult;
import com.xuecheng.manage_cms.dao.CmsSiteRepository;
import com.xuecheng.manage_cms.service.CmsSiteService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CmsSiteServiceImpl implements CmsSiteService {
    @Resource
    private CmsSiteRepository cmsSiteRepository;


    /**
     * 查询所有的Cms站点信息
     *
     * @return 查询出的结果封装成统一返回对象
     */
    @Override
    public QueryResponseResult findAllSite() {
        List<CmsSite> all = cmsSiteRepository.findAll();
        // 创建查询返回对象
        QueryResult<CmsSite> queryResult = new QueryResult<>();
        queryResult.setList(all);
        queryResult.setTotal(all.size());
        // 创建统一返回对象
        return new QueryResponseResult(CommonCode.SUCCESS, queryResult);
    }
}
